package com.dongbao.util;

import com.dongbao.data.Datacenter;
import com.dongbao.service.MyMqttClient;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class MtqqUtil {

    /**
     * 刷新当前客户端的订阅信息
     * */
    public static void referSub(){
        /* 取消所有的订阅信息 */

        /* 订阅当前IP的消息 */
        ExecutorService executor = Executors.newSingleThreadExecutor();
        Future<Integer> future = executor.submit(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                Datacenter.myMqttClient = new MyMqttClient();
                Datacenter.myMqttClient.subTopic(MyMqttClient.TOPIC_PREFIX+Datacenter.clientIp);
                /* 订阅群聊天面板消息 */
                Datacenter.myMqttClient.subTopic(MyMqttClient.TOPIC_PREFIX+MyMqttClient.TOPIC_ALL);
                return 3;
            }
        });
    }

}
